import request from "../utils/http.ts";
import {AddressVO} from "../type/address";

/**
 * 获取用户地址
 * @param id
 * */
export function getAddressByIdAPI(id:number) {
    return request<AddressVO>({
        url: `/address/get/${id}`,
        method: 'GET',
    })
}

/**
* 获取全部用户地址
* */
export function getAddressesAPI() {
    return request<AddressVO[]>({
        url: `/address//list`,
        method: 'GET',
    })
}

/**
 * 移除地址
 * */
export function removeDeliveryAddressAPI(id:number) {
    return request<Boolean>({
        url: `/address/delete?id=${id}`,
        method: 'GET',
    })
}

/**
 * 添加地址
 * */
export function add(form:AddressVO) {
    return request<AddressVO>({
        url: 'address/add',
        method: 'post',
        data: form
    })
}

/**
 * 修改地址
 * */
export function update(form:AddressVO) {
    return request<Boolean>({
        url: 'address/update',
        method: 'post',
        data: form
    })
}

